package mylibrary.socket;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	public static void main(String[] args) throws Exception {
		
		ServerSocket server = new ServerSocket(100);
		
		Socket socket = server.accept();
		
		if(socket != null) {
			
			InputStream a= socket.getInputStream();
			
			//System.out.println(socket.getInputStream());
			
			//FileOutputStream  fos = new FileOutputStream("D:\\abc.txt");
			FileOutputStream  fos = new FileOutputStream("D:\\Working area\\gaoshuai\\test.dat");
			
			byte[] b = new byte[1024];
			int noOfBytes = 0;
			while ((noOfBytes = a.read(b, 0, b.length)) != -1) {
				fos.write(b, 0, noOfBytes);
			}
			a.close();
			fos.close();
		}
		socket.close();
		
	}
}
